package com.ruicar.afs.cloud.finance.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruicar.afs.cloud.common.modules.contract.enums.UnusedFundsStatusEnums;
import com.ruicar.afs.cloud.finance.common.entity.FinanceCustUnusedFunds;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
 * @author: Lee
 * @date 2020-05-29 07:05:52 
 * @description 
 */
public interface FinanceCustUnusedFundsMapper extends BaseMapper<FinanceCustUnusedFunds> {

    /**
     * 收款金额分配完成时更新响应的待分配款项表
     * @author ZC.GUO
     * @param var1 剩余金额
     * @param var2 状态
     * @param var3 id
     * @param var4 乐观锁
     * @return
     */
    @Update({"update finance_cust_unused_funds set amount  = #{amount},status = #{status}, revision = revision + 1 where id=#{id} and revision=#{revision}"})
    int updateWhenDistribution(@Param("amount") BigDecimal var1, @Param("status") UnusedFundsStatusEnums var2, @Param("id") Long var3,@Param("revision") Long var4);

    /**
     * 发起金额分配时更新相应的当前待分配款项
     * @author ZC.GUO
     * @param var1 状态
     * @param var2 id
     * @param var3 乐观锁
     * @return
     */
    @Update({"update finance_cust_unused_funds set status = #{status}, revision = revision + 1 where id=#{id} and revision=#{revision}"})
    int updateWhenStartDistribution(@Param("status") UnusedFundsStatusEnums var1, @Param("id") Long var2,@Param("revision") Long var3);
}
